/**
 * Copyright 2011 Ivan Hristov
 *
 * hristov.iv [AT] gmail [DOT] com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 */
package com.google.code.johanna.jsmp {
  import com.google.code.johanna.jsmp.PacketType._

  /**
   *
   * @author Ivan Hristov
   *
   */
  abstract class Packet(val packetType: PacketType, val dstAddress: String, val srcAddress: String, val payloadType: String, val payload: String)

  abstract class QueryPacket(packetType: PacketType, dstAddress: String, srcAddress: String,
    queryId: Long, payloadType: String, payload: String) extends Packet(packetType, dstAddress, srcAddress, payloadType, payload)

  case class Message(override val dstAddress: String, override val srcAddress: String, override val payloadType: String, override val payload: String)
    extends Packet(PacketType.MESSAGE, dstAddress, srcAddress, payloadType, payload)

  case class MessageError(override val dstAddress: String, override val srcAddress: String, override val payloadType: String, override val payload: String, errorPayload: String)
    extends Packet(PacketType.MESSAGE_ERROR, dstAddress, srcAddress, payloadType, payload: String) 

  case class Query(override val dstAddress: String, override val srcAddress: String, queryId: Long, override val payloadType: String, override val payload: String)
    extends QueryPacket(PacketType.QUERY, dstAddress, srcAddress, queryId, payloadType, payload)

  case class QueryError(override val dstAddress: String, override val srcAddress: String, queryId: Long, override val payloadType: String, override val payload: String, errorPayload: String)
    extends QueryPacket(PacketType.QUERY_ERROR, dstAddress, srcAddress, queryId, payloadType, payload) 

  case class Response(override val dstAddress: String, override val srcAddress: String, queryId: Long, override val payloadType: String, override val payload: String)
    extends QueryPacket(PacketType.RESPONSE, dstAddress, srcAddress, queryId, payloadType, payload)

}